package cn.iocoder.yudao.module.xhyy.controller.app.beikao;

import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import org.springframework.validation.annotation.Validated;

import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;


import cn.iocoder.yudao.module.xhyy.controller.app.beikao.vo.*;
import cn.iocoder.yudao.module.xhyy.dal.dataobject.beikao.BeikaoDO;
import cn.iocoder.yudao.module.xhyy.service.beikao.BeikaoService;

import java.util.List;
import java.util.Map;

@Tag(name = "用户 APP - 高三资源")
@RestController
@RequestMapping("/xhyy/beikao")
@Validated
public class AppBeikaoController {

    @Resource
    private BeikaoService beikaoService;


    @GetMapping("/get")
    @Operation(summary = "获得高三资源")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<AppBeikaoRespVO> getBeikao(@RequestParam("id") String id) {
        BeikaoDO beikao = beikaoService.getBeikao(id);
        return success(BeanUtils.toBean(beikao, AppBeikaoRespVO.class));
    }


    @GetMapping("/page")
    @Operation(summary = "获得高三资源分页")
    public CommonResult<PageResult<AppBeikaoRespVO>> getBeikaoPage(@Valid AppBeikaoPageReqVO pageReqVO) {
        PageResult<BeikaoDO> pageResult = beikaoService.getBeikaoPage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, AppBeikaoRespVO.class));
    }

    @GetMapping("/getYear")
    @Operation(summary = "获取资源年份")
    public CommonResult<List<Object>> getYear(@Valid AppBeikaoPageReqVO pageReqVO) {
        List<Object> years = beikaoService.getYears(pageReqVO.getType());
        return success(years);
    }

}